//可否下拉
var is_bool=true;
// 页码信息
var page_no=1;



$(function() {
    getTopicList();

    $(window).scroll(function(){
    　　var scrollTop = $(this).scrollTop();
    　　var scrollHeight = $(document).height();
    　　var windowHeight = $(this).height();
    　　if(scrollTop + windowHeight == scrollHeight&&is_bool){
    　　　　getTopicList();
    　　}
    });
})



function getTopicList() {
    //禁止滚动
    is_bool=false;
    $('.load').show();
    $.ajax({
        type: "post",
        url: "Api/Topic/getTopicList",
        data: {
            park_id: $('#park_id').val(),
            page_no:page_no
        },
        async: true,
        dataType: 'json',
        success: function(data) {
            if (data.status) {
                setTimeout(function(){
                    $('.load').hide();
                    var t = JSON.parse(data.v);
                    $('.search-result lable').eq(0).html(t.count);
                    $.each(t.data, function(k, v) {
                        $('.fenXiang-demo li').attr('data-topic_id',v.id);
                        $('.fenXiang-demo .topic-title').html(v.title);
                        $('.fenXiang-demo .topic-content').html(v.content);
                        $('.fenXiang-demo .topic-creator-char').html(v.creator_char);
                        $('.fenXiang-demo .topic-browse-count').html(v.browse_count);
                        $('.fenXiang-demo .topic-comments-count').html(v.comments_count);
                        $('.fenXiang ul').append($('.fenXiang-demo').html());
                    });
                    is_bool=t.have;
                    page_no++;
                    if(!t.have){
                        $('.no-data').show();
                    }
                },1000);
                // lazyLoad();
                // $(window).scroll();
            } else {

            }
        }
    });
}

function toTopicContent(obj){
    location.href=getRootPath()+'/GasHome/Topic/topicContent?park_id='+$('#park_id').val()+'&topic_id='+$(obj).attr('data-topic_id');
}
